#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
int map[100][100];
bool is_come[100][100];
int seedx,seedy;
void dfs(int x,int y,int n,int m)
{
    if(x<1||x>n||y<1||y>m)return ;
    int next_x,next_y;
    for(int k=0;k<4;k++)
    {
        next_x=x+dx[k];
        next_y=y+dy[k];
        if(map[next_x][next_y]==map[x][y]&&x>=1&&x<=n&&y>=1&&y<=m&&!is_come[next_x][next_y])
        {
            is_come[next_x][next_y]=true;
            dfs(next_x,next_y,n,m);
            is_come[next_x][next_y]=false;
        }
    }
    map[x][y]=0;
    return ;
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>map[i][j];
        }
    }
    memset(is_come,0,sizeof(is_come));
    cin>>seedx>>seedy;
    is_come[seedx][seedy]=true;
    dfs(seedx,seedy,n,m);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cout<<map[i][j]<<' ';
        }
        cout<<endl;
    }
    return 0;
}